//
//  RootViewController.m
//  HideBar
//
//  Created by Naoki TSUTSUI on 10/02/05.
//  Copyright 2010 iphoneworld.jp. All rights reserved.
//

#import "RootViewController.h"
#import "DummyDetailViewController.h"


@implementation RootViewController

@synthesize menuArray;

- (void)dealloc {
  [menuArray release];
  [super dealloc];
}

- (void)viewDidLoad {
  [super viewDidLoad];

  self.title = @"メイン";
  
  menuArray = [NSMutableArray array];
  [menuArray addObject:@"ナビゲーションバーを隠す"];
  [menuArray addObject:@"タブバーを隠す"];
  [menuArray addObject:@"上下のバーを隠す"];
}


- (void)viewWillAppear:(BOOL)animated {
  [super viewWillAppear:animated];
}


/*
- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
}
*/
/*
- (void)viewWillDisappear:(BOOL)animated {
	[super viewWillDisappear:animated];
}
*/
/*
- (void)viewDidDisappear:(BOOL)animated {
	[super viewDidDisappear:animated];
}
*/

- (void)didReceiveMemoryWarning {
	// Releases the view if it doesn't have a superview.
  [super didReceiveMemoryWarning];
	
	// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
	// Release any retained subviews of the main view.
	// e.g. self.myOutlet = nil;
}


#pragma mark Table view methods

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 3;
}


// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}


// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
  static NSString *CellIdentifier = @"Cell";
    
  UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault 
                                   reuseIdentifier:CellIdentifier] autorelease];
  }
    
  // Set up the cell...
  
  cell.textLabel.text = [menuArray objectAtIndex:indexPath.section];

  return cell;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

	DummyDetailViewController *anotherViewController;
  anotherViewController = [[DummyDetailViewController alloc] 
                           initWithNibName:@"DummyDetailViewController" bundle:nil];
  
  // タブバー非表示の指定は遷移直前に行い、ナビゲーションバーは遷移後に行う
  switch (indexPath.section) {
    case 0:
      break;
    case 1:
      // 画面遷移後にタブバーを隠す（戻った時に再表示させる処理は不要）
      anotherViewController.hidesBottomBarWhenPushed = YES;
      break;
    case 2:
      // 画面遷移後にタブバーを隠す（戻った時に再表示させる処理は不要）
      anotherViewController.hidesBottomBarWhenPushed = YES;
      break;
    default:
      break;
  }
  
  // 遷移後のビュー内で、ナビゲーションバーを非表示にするかどうかの判断に使用する。
  anotherViewController.indexPath = indexPath;
  
  [self.navigationController pushViewController:anotherViewController animated:YES];
	[anotherViewController release];
}
@end

